﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Habi.Solver.Common;
using DevExpress.XtraEditors;
using Habi.Solver.ViewModels.Meta;
using Habi.Solver.Services;
using DevExpress.Utils.MVVM;
using DotNetExtensions.AspNet.DevExpress.Services;

namespace Habi.Solver.Views.Meta
{
    public partial class LoginView : ExtensionControl<LoginViewModel>
    {
        public LoginView() : base()
        {
            InitializeComponent();

            mvvmContext.RegisterService(new DialogMessageBoxService(this));
            mvvmContext.RegisterService(new ControlOperationService(this));
        }

        public override void InitializeView(MVVMContextFluentAPI<LoginViewModel> fluent)
        {
            base.InitializeView(fluent);

            fluent.SetBinding(textEditId, t => t.Text, x => x.UserId);
            fluent.SetBinding(textEditPwd, t => t.Text, x => x.UserPwd);

            fluent.BindCommand(simpleButtonEnter, x => x.Enter());
            fluent.BindCommand(simpleButtonQuit, x => x.Quit());
            fluent.BindCommand(hyperlinkLabelControlRegist, x => x.RegistNew());
        }
    }
}
